package com.shijunhao.graduation.properties;

import com.shijunhao.graduation.handler.auth.NoneAuthHandlerImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.security.web.authentication.AuthenticationFailureHandler;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;

/**
 * @author: shijunhao
 * @date: 2022/3/3 14:55
 * @description:
 */
@Configuration
public class WebSecurityProperties {
    public final static String loginUrl = "/login";

    public final static String logoutUrl = "/logout";

    public final static String username = "username";

    public final static String password = "password";

    public final static String[] permitUrls = {"/css/**", "/js/**", "/webjars/**", "/doc.html", "/swagger-resources", "/v2/**","/currentUser","/registry"};
    public final static String[] loginUrls = {"/**/insert/**","/**/update/**","/**/delete/**","/admin/**"};

    public final AuthenticationSuccessHandler authSuccessHandler;

    public final LogoutSuccessHandler logoutSuccessHandler;

    public final AuthenticationFailureHandler authenticationFailureHandler;

    public final AuthenticationEntryPoint noneAuthHandler = new NoneAuthHandlerImpl();

    @Autowired
    public WebSecurityProperties(AuthenticationSuccessHandler authSuccessHandler, LogoutSuccessHandler logoutSuccessHandler, AuthenticationFailureHandler authenticationFailureHandler) {
        this.authSuccessHandler = authSuccessHandler;
        this.logoutSuccessHandler = logoutSuccessHandler;
        this.authenticationFailureHandler = authenticationFailureHandler;
    }
}
